import 'dart:convert';

import 'package:crypto/crypto.dart';
import 'package:convert/convert.dart';
import 'package:xinxuan/config/app_config.dart';
import 'package:xinxuan/utils/key_sort_util.dart';

class SignUtil {

  static String getSign(Map<String, dynamic> param) {
    String keySortStr = KeySortUtil.keySortAndRemoveEqual(param);
    keySortStr += AppConfig.secretKey;
    var content = new Utf8Encoder().convert(keySortStr);
    var digest = md5.convert(content);
    String md5Str = hex.encode(digest.bytes);

    var md5StrContent = new Utf8Encoder().convert(md5Str);
    var sha1Digest = sha1.convert(md5StrContent);
    return hex.encode(sha1Digest.bytes);
  }

}